import request from '@/utils/request';

export async function getToolInfoByPage(params: any) {
  return request('/api/device/getToolInfoByPage', {
    method: 'POST',
    data: params,
  });
}

export async function addToolInfo(params: any) {
  return request('/api/device/addToolInfo', {
    method: 'POST',
    data: params,
  });
}

export async function updateToolInfo(params: any) {
  return request('/api/device/updateToolInfo', {
    method: 'POST',
    data: params,
  });
}

export async function delToolInfo(params: any) {
  return request('/api/device/delToolInfo', {
    method: 'POST',
    data: params,
  });
}

export async function getCategoryDict() {
  return request('/api/device/getCategoryDict', {
    method: 'POST',
  });
}

export async function exportToolInfo(params: any) {
  return request('/api/device/exportToolInfo', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}
//ToolFile
export async function addToolFile(params: any) {
  return request('/api/device/addToolFile', {
    method: 'POST',
    data: params,
  });
}

export async function delToolFile(params: any) {
  return request('/api/device/delToolFile', {
    method: 'POST',
    data: params,
  });
}

export async function exportToolFile(params: any) {
  return request('/api/device/exportToolFile', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

export async function getToolFileByPage(params: any) {
  return request('/api/device/getToolFileByPage', {
    method: 'POST',
    data: params,
  });
}

export async function updateToolFile(params: any) {
  return request('/api/device/updateToolFile', {
    method: 'POST',
    data: params,
  });
}

export async function uploadToolFile(para: any) {
  return request('/api/device/uploadToolFile', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    params: {
      toolinfoId: para.toolinfoId,
      memo: para.memo,
      fileName: para.fileName,
    },
  });
}
export default {
  getToolInfoByPage,
  addToolInfo,
  updateToolInfo,
  getCategoryDict,
  delToolInfo,
  exportToolInfo,
  addToolFile,
  delToolFile,
  exportToolFile,
  getToolFileByPage,
  updateToolFile,
  uploadToolFile,
};
